<template>
  <el-dialog
    :visible.sync="modals"
    scrollable
    :title="title"
    class="order_box"
    :closable="false"
    width="1000"
    :mask-closable="false"
  >
    <el-card :bordered="false" shadow="never" class="i-table-no-border">
      <el-form ref="formItem" :model="formItem" label-width="100px" @submit.native.prevent>
        <el-form-item label="实际金额：">
          <el-input v-model="formItem.pay_price" type="number" />
        </el-form-item>
      </el-form>
    </el-card>
    <div slot="footer">
      <el-button @click="cancel">取消</el-button>
      <el-button type="primary" @click="putSend">确认修改</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { getOrderInfoApi, confirmEditOrderApi } from '@/api/onsite';
export default {
  name: 'orderPrice',
  props: {
    orderId: Number,
  },
  data() {
    return {
      title: '修改订单',
      order_info: null,
      modals: false,
      send_locked: false,
      formItem: {},
      pliceData: [],
      itemData: [],
    };
  },
  methods: {
    // 订单详情
    getOrderInfo() {
      getOrderInfoApi(this.orderId)
        .then(async (res) => {
          this.formItem = res;
          this.modals = true;
        })
    },
    // 提交
    putSend() {
      if (this.send_locked) {
        return this.$message.error('请勿重复提交');
      }
      this.send_locked = true;
      let form = {
        id: this.formItem.id,
        payPrice: this.formItem.pay_price,
      };
      confirmEditOrderApi(form)
        .then(async (res) => {
          this.send_locked = false;
          this.$message.success('操作成功');
          this.$emit('submitOk');
          let that = this;
          setTimeout(function () {
            that.modals = false;
          }, 1500);
        })
        .catch((res) => {
          this.send_locked = false;
          this.$message.error('操作失败');
        });
    },
    cancel(name) {
      this.modals = false;
      this.$emit('clearId');
    },
  },
};
</script>

<style scoped lang="stylus">
.ivu-description-list-title {
  margin-bottom: 30px;
  color: #17233d;
  font-weight: bold;
  font-size: 14px;
}

.ivu-table th {
  background-color: #f8f8f9 !important;
}

.express_temp_id {
  position: relative;
}

.express_temp_id button {
  position: absolute;
  top: 50%;
  right: 110px;
  padding: 0;
  border: none;
  background: none;
  transform: translateY(-50%);
  color: #57a3f3;
}

.ivu-btn-text:focus {
  box-shadow: none;
}

.trips {
  color: #ccc;
}

.product-data {
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-data .image {
  width: 50px !important;
  height: 50px !important;
}

.line2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
</style>
